﻿using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;

namespace HttpClientTest
{
    class Program
    {
        const string url1 = "https://www.xindiziyuan.cn/wp-content/themes/ripro/assets/css/app.css?ver=7.2.0";
        const string url2 = "https://www.xindiziyuan.cn/";
        const string url3 = "https://oss-cdn.xindiziyuan.cn/upload/2020/07/1595905386-1b568289b9f6df3.jpg";
        static void Main(string[] args)
        {
            TaskFactory tk = new TaskFactory();
            //HttpClientFactory fac =;
            //List<Task> tks = new List<Task>();
            //List<string> rs = new List<string>();
            while (true)
            {
                var task = tk.StartNew(async () =>
                {
                    using (HttpClient httpClient = HttpClientFactory.Create())
                    {
                        string s = "默认";
                        try
                        {
                            var r = await httpClient.GetAsync(url1);
                            var r2 = await httpClient.GetAsync(url3);
                            //var r2 = httpClient.GetAsync(url2).GetAwaiter().GetResult();
                            //rs.Add(r.StatusCode.ToString());
                            Console.WriteLine(r.StatusCode.ToString() + "," + r2.StatusCode.ToString());
                            //Console.WriteLine($"{s},{r2.StatusCode.ToString()}");
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }


                    }
                    //tks.Add(task);
                });
                Thread.Sleep(50);
            }
            //Console.Read();
        }
    }
}
